<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <div>
        <h3>{{count}}</h3>
        <h3>info->{{info}}</h3>
        <h3>info.age->{{info.age}}</h3>
        <h3>info.size.h->{{info.size.h}}</h3>
      </div>
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          count: 100,
          info: {
            age: 20,
            size: {
              h: 200,
              w: 200,
            },
          },
        },
        watch: {
          // 监听count属性
          count(newValue, oldValue) {
            console.log("count", newValue, oldValue);
          },
          "info.age": function (newValue, oldValue) {
            console.log("info.age", newValue, oldValue);
          },
          "info.size.h": function (newValue, oldValue) {
            console.log("info.size.h", newValue, oldValue);
          },
        },

        mounted() {
          setTimeout(() => {
            this.info.size.h++;
          }, 3000);
        },
      });
    </script>
  </body>
</html>
